/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.click.app.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author orgale
 */
@Entity
@Table(name = "delivery")
@NamedQueries({@NamedQuery(name = "Delivery.findAll", query = "SELECT d FROM Delivery d"), @NamedQuery(name = "Delivery.findByIdDelivery"
                                                    , query = "SELECT d FROM Delivery d WHERE d.idDelivery = :idDelivery"), @NamedQuery(name = "Delivery.findByDescription"
                                                    , query = "SELECT d FROM Delivery d WHERE d.description = :description"), @NamedQuery(name = "Delivery.findByQuantity"
                                                    , query = "SELECT d FROM Delivery d WHERE d.quantity = :quantity"), @NamedQuery(name = "Delivery.findByDate"
                                                    , query = "SELECT d FROM Delivery d WHERE d.date = :date")})
                                                    
public class Delivery extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1L;
    
    private Integer idDelivery;
    private String description;
    private Double quantity;
    private Date date;
    private Material idMaterial;

    public Delivery() {  }

    public Delivery(Integer idDelivery) {
        this.idDelivery = idDelivery;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Basic(optional = false)
    @Column(name = "id_delivery")
    public Integer getIdDelivery() {
        return idDelivery;
    }

    public void setIdDelivery(Integer idDelivery) {
        this.idDelivery = idDelivery;
    }

    @Column(name = "description")
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name = "quantity")
    public Double getQuantity() {
        return quantity;
    }

    public void setQuantity(Double quantity) {
        this.quantity = quantity;
    }

    @Column(name = "date")
    @Temporal(TemporalType.DATE)
    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    @JoinColumn(name = "id_material", referencedColumnName = "id_material")
    @ManyToOne(optional = false)
    public Material getIdMaterial() {
        return idMaterial;
    }

    public void setIdMaterial(Material idMaterial) {
        this.idMaterial = idMaterial;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idDelivery != null ? idDelivery.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Delivery)) {
            return false;
        }
        Delivery other = (Delivery) object;
        if ((this.idDelivery == null && other.idDelivery != null) || (this.idDelivery != null && !this.idDelivery.equals(other.idDelivery))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.click.app.model.Delivery[idDelivery=" + idDelivery + "]";
    }

}
